package org.adorsys.aderp.cash.service;

import java.util.Map;

import org.adorsys.aderp.cash.domain.CashRegister;
import org.adorsys.aderp.cash.repository.CashRegisteRepository;
import org.adorsys.aderp.cash.work.cashstate.CashRegisterState;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;


public class CashRegisterServiceImpl implements CashRegisterService {
    @Autowired
    CashRegisteRepository cashRegisteRepository;
    public void saveCashRegister(CashRegister cashRegister) {
        System.out.println("Cash register repository Started");
        cashRegisteRepository.save(cashRegister);
        System.out.println("Cash register repository Donne");
    }
	public void addCashRegister(Map<CashRegister, CashRegisterState> cashOfTheDay, CashRegister cashRegister,CashRegisterState cashRegisterState){
		if(cashOfTheDay.isEmpty())return;
		Assert.notNull(cashRegister, "The cash must not be null");
		Assert.notNull(cashRegisterState, "The cash registerstate must not be null");
//		if(cashOfTheDay.containsKey(cashRegister) && cashOfTheDay.get(cashRegister).equals(CashRegisterState.OPEN)) return ;
		if(!cashOfTheDay.containsKey(cashRegister)){
			cashOfTheDay.put(cashRegister, cashRegisterState);
		}else{
			cashOfTheDay.put(cashRegister, cashRegisterState);
		}
	}
}
